var e = require;
var t = module;
var o = exports;
var n,
    i = o,
    a =
        ((n = function (e, t) {
            return (n =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (e, t) {
                        e.__proto__ = t;
                    }) ||
                function (e, t) {
                    for (var o in t) t.hasOwnProperty(o) && (e[o] = t[o]);
                })(e, t);
        }),
        function (e, t) {
            function o() {
                this.constructor = e;
            }
            n(e, t), (e.prototype = null === t ? Object.create(t) : ((o.prototype = t.prototype), new o()));
        }),
    r = function (e, t, o, n) {
        var i,
            a = arguments.length,
            r = a < 3 ? t : null === n ? (n = Object.getOwnPropertyDescriptor(t, o)) : n;
        if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(e, t, o, n);
        else
            for (var s = e.length - 1; s >= 0; s--)
                (i = e[s]) && (r = (a < 3 ? i(r) : a > 3 ? i(t, o, r) : i(t, o)) || r);
        return a > 3 && r && Object.defineProperty(t, o, r), r;
    };
Object.defineProperty(i, "__esModule", {value: !0});
var s = e("Util"),
    c = e("WechatExportManager"),
    l = e("AdItem"),
    d = cc._decorator,
    u = d.ccclass,
    p = d.property,
    h = (function (e) {
        function t() {
            var t = (null !== e && e.apply(this, arguments)) || this;
            return (
                (t.node_content = null),
                (t.node_ad_content = null),
                (t.node_layout = null),
                (t.node_item = null),
                (t.node_btn_sideslip = null),
                (t.node_arrow = null),
                (t.node_mask = null),
                (t._showGameList = []),
                (t._ad_content_size = cc.Size.ZERO),
                (t._isOpen = !1),
                t
            );
        }
        return (
            a(t, e),
            (t.prototype.start = function () {
                for (var e = this; this._showGameList.length < 50 && c.default.instance.gameList.length > 0; )
                    this._showGameList = this._showGameList.concat(c.default.instance.gameList);
                s.default.shuffle(this._showGameList);
                for (var t = 0; t < Math.min(12, this._showGameList.length); t++) {
                    var o = this._showGameList[t];
                    if (!o) break;
                    var n = cc.instantiate(this.node_item);
                    (n.active = !0),
                        (n.position = cc.Vec3.ZERO),
                        n.getComponent(l.default).setData(o),
                        this.node_layout.addChild(n);
                }
                this.scheduleOnce(function () {
                    cc.winSize.width > cc.winSize.height
                        ? (e._ad_content_size = cc.size(580, 530))
                        : e.node.width < e.node.height && (e._ad_content_size = cc.size(442, 693)),
                        e.node_ad_content.setContentSize(e._ad_content_size),
                        (e.node_content.x = 0 - cc.winSize.width / 2 + 74),
                        e.node_layout.getComponent(cc.Widget).updateAlignment(),
                        e.node_layout.getComponent(cc.Layout).updateLayout();
                }),
                    this.addEvent();
            }),
            (t.prototype.addEvent = function () {
                this.node_btn_sideslip.on("click", this.onClickSideslip, this);
            }),
            (t.prototype.onClickSideslip = function () {
                var e = this,
                    t = 0;
                this._isOpen
                    ? ((t = 0 - cc.winSize.width / 2 + 74), (this._isOpen = !1), (this.node_arrow.scaleX = -1))
                    : ((t = 0 - cc.winSize.width / 2 + this.node_content.width),
                      (this._isOpen = !0),
                      (this.node_arrow.scaleX = 1)),
                    cc.Tween.stopAllByTarget(this.node_content),
                    cc.tween(this.node_content).to(0.3, {x: t}).start(),
                    this._isOpen && (this.node_mask.active = !0),
                    cc.Tween.stopAllByTarget(this.node_mask),
                    cc
                        .tween(this.node_mask)
                        .to(0.3, {opacity: this._isOpen ? 150 : 0})
                        .call(function () {
                            e._isOpen || (e.node_mask.active = !1);
                        })
                        .start(),
                    this._isOpen && this.refreshAdData();
            }),
            (t.prototype.refreshAdData = function () {
                s.default.shuffle(this._showGameList);
                for (var e = this.node_layout.children, t = 0; t < e.length; t++) {
                    var o = this._showGameList[t];
                    if (!o) break;
                    var n = e[t];
                    n.getComponent(l.default).setData(o), n.getComponent(l.default).updateView();
                }
            }),
            r([p(cc.Node)], t.prototype, "node_content", void 0),
            r([p(cc.Node)], t.prototype, "node_ad_content", void 0),
            r([p(cc.Node)], t.prototype, "node_layout", void 0),
            r([p(cc.Node)], t.prototype, "node_item", void 0),
            r([p(cc.Node)], t.prototype, "node_btn_sideslip", void 0),
            r([p(cc.Node)], t.prototype, "node_arrow", void 0),
            r([p(cc.Node)], t.prototype, "node_mask", void 0),
            r([u], t)
        );
    })(cc.Component);
i.default = h;
